package kr.hikt.androidcomplete01.ch07;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;

public class DrawText extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyView(this));
	}
	
	class MyView extends View{
		private Paint pnt;
		private String str = "Made in Korea";
		private char[] arCh = {'a', 'b', 'c'};
		
		public MyView(Context context){
			super(context);
			pnt = new Paint();
		}

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			canvas.drawColor(Color.LTGRAY);
			
			pnt.setAntiAlias(true);
			pnt.setColor(Color.BLACK);
			canvas.drawText(str, 10, 20, pnt);
			canvas.drawText(str, 2, 11, 10, 40, pnt);
			canvas.drawText(arCh, 0, 3, 10, 60, pnt);
			
			pnt.setTextAlign(Paint.Align.LEFT);
			canvas.drawText("Left Align", 100, 90, pnt);
			pnt.setTextAlign(Paint.Align.CENTER);
			canvas.drawText("CENTER Align", 100, 110, pnt);
			pnt.setTextAlign(Paint.Align.RIGHT);
			canvas.drawText("RIGHT Align", 100, 130, pnt);
			
			pnt.setTextAlign(Paint.Align.LEFT);
			pnt.setColor(Color.RED);
			canvas.drawText("Small", 10, 180, pnt);
			pnt.setTextSize(20);
			canvas.drawText("Mid", 40, 180, pnt);
			pnt.setTextSize(30);
			canvas.drawText("Big", 80, 180, pnt);
			pnt.setTextSize(40);
			canvas.drawText("Hy", 125, 180, pnt);
			
			pnt.setColor(Color.BLUE);
			pnt.setTextAlign(Paint.Align.LEFT);
			pnt.setTextSize(30);
			pnt.setTypeface(Typeface.create((String)null, Typeface.BOLD));
			pnt.setUnderlineText(true);
			pnt.setStrikeThruText(true);
			pnt.setSubpixelText(true);
			pnt.setTextSkewX(-0.25f);
			pnt.setTextScaleX(0.8f);
			canvas.drawText(str, 10, 220, pnt);
		}
		
		
	}
}
